package com.ruoyi.merchant.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.merchant.domain.AbilityassessmentDailylife;
import com.ruoyi.merchant.service.IAbilityassessmentDailylifeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 能力评估-日常生活活动Controller
 * 
 * @author chengxin.ju
 * @date 2023-12-24
 */
@RestController
@RequestMapping("/dailylife")
public class AbilityassessmentDailylifeController extends BaseController
{
    @Autowired
    private IAbilityassessmentDailylifeService abilityassessmentDailylifeService;

    /**
     * 查询能力评估-日常生活活动列表
     */
    @RequiresPermissions("system:dailylife:list")
    @GetMapping("/list")
    public TableDataInfo list(AbilityassessmentDailylife abilityassessmentDailylife)
    {
        startPage();
        List<AbilityassessmentDailylife> list = abilityassessmentDailylifeService.selectAbilityassessmentDailylifeList(abilityassessmentDailylife);
        return getDataTable(list);
    }

    /**
     * 导出能力评估-日常生活活动列表
     */
    @RequiresPermissions("system:dailylife:export")
    @Log(title = "能力评估-日常生活活动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AbilityassessmentDailylife abilityassessmentDailylife)
    {
        List<AbilityassessmentDailylife> list = abilityassessmentDailylifeService.selectAbilityassessmentDailylifeList(abilityassessmentDailylife);
        ExcelUtil<AbilityassessmentDailylife> util = new ExcelUtil<AbilityassessmentDailylife>(AbilityassessmentDailylife.class);
        util.exportExcel(response, list, "能力评估-日常生活活动数据");
    }

    /**
     * 获取能力评估-日常生活活动详细信息
     */
    @RequiresPermissions("system:dailylife:query")
    @GetMapping(value = "/{baseId}")
    public AjaxResult getInfo(@PathVariable("baseId") String baseId)
    {
        return success(abilityassessmentDailylifeService.selectAbilityassessmentDailylifeByBaseId(baseId));
    }

    /**
     * 新增能力评估-日常生活活动
     */
    @RequiresPermissions("system:dailylife:add")
    @Log(title = "能力评估-日常生活活动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AbilityassessmentDailylife abilityassessmentDailylife)
    {
        return toAjax(abilityassessmentDailylifeService.insertAbilityassessmentDailylife(abilityassessmentDailylife));
    }

    /**
     * 修改能力评估-日常生活活动
     */
    @RequiresPermissions("system:dailylife:edit")
    @Log(title = "能力评估-日常生活活动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AbilityassessmentDailylife abilityassessmentDailylife)
    {
        return toAjax(abilityassessmentDailylifeService.updateAbilityassessmentDailylife(abilityassessmentDailylife));
    }

    /**
     * 删除能力评估-日常生活活动
     */
    @RequiresPermissions("system:dailylife:remove")
    @Log(title = "能力评估-日常生活活动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{baseIds}")
    public AjaxResult remove(@PathVariable String[] baseIds)
    {
        return toAjax(abilityassessmentDailylifeService.deleteAbilityassessmentDailylifeByBaseIds(baseIds));
    }
}
